chore(main): release 6.20.0 #4641
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🌱 A new release!
6.20.0 (2025-09-17)
The MongoDB Node.js team is pleased to announce version 6.20.0 of the
mongodb
package!Release Notes
Collection
andDb
objects now provide references to theirDb
andMongoClient
Hint is supported with unacknowledged writes for delete, update and findAndModify commands on servers that support hint
The driver no longer throws errors when
hint
is provided to unacknowledged writes fordelete
,update
andfindAndModify
commands in the following circumstances:update
commands.delete
andfindAndModify
commands on servers >=4.4.ServerCapabilities and ReadPreference.minWireVersion are deprecated
Neither the
ServerCapabilities
class nor theReadPreference.minWireVersion
property were ever intended for public use and, internally, are effectively dead code with the driver's minimum supported server version being 4.2.Driver info and metadata MongoClient options have been deprecated.
These will be made internal in a future major release:
driverInfo
additionalDriverInfo
metadata
extendedMetadata
CommandOperationOptions.retryWrites
is deprecatedCommandOperationOptions.retryWrites
is deprecated. This per‑command option has no effect; the Node.js driver only honorsretryWrites
when configured at the client level (MongoClient options) or via the connection string. Do not use this option on individual commands. There is no runtime behavior change because it was already ignored, but it will be removed in an upcoming major release and may cause type or build errors in code that references it. To control retryable writes, setretryWrites
in MongoClient options or includeretryWrites=true|false
in the connection string.ChangeStream
.tryNext()
now updatesresumeToken
to prevent duplicates after resumeWhen
.tryNext()
returns a change document, the driver now caches itsresumeToken
, aligning its behavior with.next()
and the'change'
event. If.tryNext()
returnsnull
(no new changes), nothing is cached, which is unchanged from previous behavior.Previously,
.tryNext()
did not update theresumeToken
, so a resumable error could cause a resume from an older token and re-deliver already processed changes. With this release, resumes continue from the latest token observed via.tryNext()
, preventing duplicates.Applications that poll change streams with
.tryNext()
in non-blocking loops benefit directly. There are no API changes; if you previously tracked and passedresumeAfter
orstartAfter
manually, you can now rely on the driver’s built-in token caching.Huge thanks to @rkistner for bringing this bug to our attention and for sharing code to reproduce it. Huge thanks as well to @Omnicpie for investigating and implementing a fix.
Change Streams now resume on
MongoServerSelectionError
When the driver encounters a
MongoServerSelectionError
while processing a Change Stream (e.g., due to a transient network issue or during an election), it now treats the error as resumable and attempts to resume using the latest cached resume token.This applies to both iterator and event-emitter usage:
There are no API changes. If you previously caught
MongoServerSelectionError
and implemented manual resume logic, you can now rely on the driver’s built-in resume mechanism, which uses the cached resume token from the change event’s_id
to continue without losing events.Huge thanks to @grossbart for bringing this bug to our attention, investigating it and for sharing code to reproduce it!
MongoClient.appendMetadata()
ignores duplicate metadataMongoClient.appendMetadata()
will no longer append metadata, if the metadata is a duplicate of metadata already appended to the MongoClient.Features
retryWrites
inCommandOperationOptions
(#4661) (620972d)Bug Fixes
resumeToken
inChangeStream.tryNext()
(#4636) (8331a93)Documentation
We invite you to try the
mongodb
library immediately, and report any issues to the NODE project.